package fr.esiea.erg5203.mvc.controllers;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import fr.esiea.erg5203.business.Contact;
import fr.esiea.erg5203.persistence.dao.AbstractDAOFactory;
import fr.esiea.erg5203.persistence.dao.DAO;

@Controller  
public class IndexController {

	@RequestMapping(value = "/index.jsp")
	public ModelAndView indexRedirection(HttpServletRequest request)
	{		
		
		DAO<Contact> contactDAO = AbstractDAOFactory.getDAOFactory().getContactDAO();			
		ModelAndView result = new ModelAndView("index");
		
		List<Contact> c = contactDAO.getAll();
		result.addObject("contacts", contactDAO.getAll());
		
		System.out.println("Index Redirection Meth");
		return result;
	}
}
